<!DOCTYPE html>
<html lang="en">
<head>
    <title>公司进个人管理层</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=4a6c1b54">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=16f1e6f3">
    <script src="https://file.ggxqce.com/web/vue.min.js"></script>
    <style>
        .reginTd {
            max-width: 105px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            position: relative;
        }

        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }

        .row {
            margin-right: -15px;
            margin-left: 0px;
        }

        .col-lg-6, .col-xs-6, .col-md-6 {
            padding-left: 0;
        }

        .nav-tabs-custom {
            margin-bottom: 10px;
        }

        .lefts {
            width: 50%;
            text-align: center;
            color: #fff;
            background: #228bee;
            border-bottom: 2px solid #228bee;
            margin-left: 8px;
            margin-right: 8px;
            cursor: pointer;
            font-weight: bold;
        }

        .rights {
            width: 50%;
            text-align: center;
            color: black;
            border-bottom: 2px solid #ffffff;
            margin-left: 8px;
            margin-right: 8px;
            cursor: pointer;
        }

        .boxs {
            width: auto;
            /*display: flex;*/
            /*justify-content: flex-start;*/
            border-bottom: 1px solid #f8f8f8;
            line-height: 24px;
            margin-bottom: 5px;
            margin-top: 5px;
        }

        .lineOne {
            text-align: left;
        }

        .lineOne span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }

    </style>
</head>
<body>
<section class="content" id="app">
    <div class="div-td-content-more"><i></i></div>
    <div class="nav-tabs-custom oaReportNav" v-cloak>
        <!-- Tabs within a box -->
        <ul class="nav nav-tabs pull-right">
            <li :class="today == visitCustomer.time && a==1?'active':''"
                @click="a=1;refreshData('visitCustomer','get_visitDepart',today)">
                <a href="#sales-chart" data-toggle="tab">今日</a>
            </li>
            <!--<li :class="today == visitCustomer.time &&a==0?'active':''" @click="a=0;refreshData('visitCustomer','get_visitDepart',today)" >-->
            <!--<a href="#sales-chart" data-toggle="tab" >今日首次面访</a>-->
            <!--</li>-->
            <!--<li :class="isActive(today)?'active':''"-->
            <!--@click="refreshData('visitCustomer','get_visitDepart',today)"><a-->
            <!--href="#sales-chart" data-toggle="tab">今日</a></li>-->
            <li :class="isActive(yesterday)?'active':''"
                @click="refreshData('visitCustomer','get_visitDepart',yesterday)"><a
                    href="#sales-chart"
                    data-toggle="tab">昨日</a></li>
            <li :class="isActive(thisWeek)?'active':''"
                @click="refreshData('visitCustomer','get_visitDepart',thisWeek)"><a
                    href="#sales-chart"
                    data-toggle="tab">本周</a></li>
            <li :class="isActive(thisMonth)?'active':''"
                @click="refreshData('visitCustomer','get_visitDepart',thisMonth)"><a
                    href="#sales-chart"
                    data-toggle="tab">本月</a></li>
            <li :class="isActive(item.time)?'active':''" v-for="(item,i) in tab"
                @click="refreshData('visitCustomer','get_visitDepart',item.time)"><a
                    href="#sales-chart"
                    data-toggle="tab">{{i==0?"上月":item.str}}</a>
            </li>
            <!--<button type="button" class="btn oaBtn btn-sm" :class="today == visitCustomer.time &&a==0?'active':''" @click="a=0;refreshData('visitCustomer','get_visitDepart',today)" style="float: right;">-->
            <!--<a href="#sales-chart" data-toggle="tab" >今日首次面访</a>-->
            <!--</button>-->
            <!--<button type="button" class="btn oaBtn btn-sm" style="float: right;"
                    @click="a=2;refreshData('visitCustomer','get_visitDepart',today)">下午首次面访报表
            </button>-->
            <button type="button" class="btn oaBtn btn-sm" style="float: right;"
                    @click="a=0;refreshData('visitCustomer','get_visitDepart',today)">上午首次面访报表
            </button>
        </ul>
    </div>

    <div style="padding: 0 10px;background: #fff;" id="visitDepart">
        <!--<div class="boxs" v-if="visitCustomer.time==today">-->
        <!--<div :class="a==1?'lefts':'rights'" @click="a=1">-->
        <!--实时数据报表-->
        <!--</div>-->
        <!--<div :class="a==1?'rights':'lefts'" @click="a=0">-->
        <!--首次面访报表-->
        <!--</div>-->
        <!--</div>-->
        <div style="width: 1100px;margin:0 auto;" class="mScrollBox">
            <table class="table text-center table-width table-bordered" v-if="a!=2">
                <thead>
                <tr>
                    <!--<th align="center" style="width:40px">序号</th>-->
                    <th style="width:6%;"  class="tableTitle"
                        v-if="!(visitCustomer.time==today &&( a==0 || a==2))">
                        面访<br>排名
                    </th>
                    <!--(visitCustomer.time.length==10 && a==1) || visitCustomer.time.length!=10-->
                    <th v-if=" !(visitCustomer.time==today  &&( a==0 || a==2))"
                        style="width:6%;" class="tableTitle">完成
                    </th>
                    <th v-if="!(visitCustomer.time==today  &&( a==0 || a==2))"
                        style="width:6%;" class="tableTitle">完成率
                    </th>
                    <th style="width:6%;" class="tableTitle">区域经理</th>
                    <th v-if="visitCustomer.time.length!=10" style="width:6%;" class="tableTitle">出勤天数</th>
                    <th v-if="visitCustomer.time.length!=10" style="width:6%;" class="tableTitle">异常天数</th>
                    <th v-if="visitCustomer.time.length!=10" style="width:6%;" class="tableTitle">日均完成</th>
                    <th v-if="visitCustomer.time.length==10"
                        style="width: 6%;border-left: 1px solid #cbcbcd;" class="tableTitle">考勤签到<br>时间
                    </th>
                    <th v-if="visitCustomer.time.length==10" style="width: 6%;" class="tableTitle">首次面访<br>签到时间</th>
                    <th v-if="visitCustomer.time.length==10" style="width: 7%;" class="tableTitle">时间间隔</th>
                    <th v-if="visitCustomer.time.length==10" style="width: 6%;" class="tableTitle">距离间隔<br>(公里)</th>
                    <th v-if="visitCustomer.time.length==10" style="width: 6%;" class="tableTitle">时速<br>(km/h)</th>
                    <th v-if="(visitCustomer.time==today && a==1)||visitCustomer.time==yesterday&&visitCustomer.time.length==10" class="tableTitle"
                        style="width: 6%;border-left: 2px solid #169bd5;">考勤签退<br>时间
                    </th>
                    <th v-if="(visitCustomer.time==today && a==1)||visitCustomer.time==yesterday&&visitCustomer.time.length==10" class="tableTitle"
                        style="width: 6%;">末次面访<br>签退时间
                    </th>
                    <th v-if="(visitCustomer.time==today && a==1)||visitCustomer.time==yesterday&&visitCustomer.time.length==10" class="tableTitle"
                        style="width: 7%;">时间间隔
                    </th>
                    <th v-if="(visitCustomer.time==today && a==1)||visitCustomer.time==yesterday&&visitCustomer.time.length==10" class="tableTitle"
                        style="width: 6%;">距离间隔<br>(公里)
                    </th>
                    <th v-if="(visitCustomer.time==today && a==1)||visitCustomer.time==yesterday&&visitCustomer.time.length==10" class="tableTitle"
                        style="width: 6%;">时速<br>(km/h)
                    </th>
                    <th style="width:6%;" class="tableTitle">大区经理</th>
                    <th style="border-left: 1px solid #cbcbcd;" class="tableTitle">大区</th>
                    <th v-if="visitCustomer.time==today &&a==0" class="tableTitle"
                        style="border-left: 1px solid #cbcbcd;width: 48%;">备注
                    </th>
                </tr>
                </thead>
                <tbody v-cloak>
                <tr v-for="(item,i) in visitCustomer.faceList">
                    <!--<td>{{i+1}}</td>-->
                    <td v-if="!(visitCustomer.time==today  &&( a==0 || a==2))">
                        {{item.rownum}}
                    </td>
                    <template
                            v-if="!(visitCustomer.time==today  &&( a==0 || a==2)) ">
                        <template v-if="isCheckRegionName(item)">
                            <td style="color:#169BD5;cursor: pointer"
                                @click="openInterview(item,'1')"
                                v-if="!(visitCustomer.time==today  &&( a==0 || a==2)) &&item.complete!='-'">
                                {{item.complete}}
                            </td>
                            <td v-else>{{item.complete}}</td>
                        </template>
                        <template v-else>
                            <td>{{item.complete}}</td>
                        </template>
                    </template>
                    <template
                            v-if="!(visitCustomer.time==today  &&( a==0 || a==2)) ">
                        <td v-if="item.completionRate!=''&&item.completionRate!='-'">
                            {{item.completionRate}}%
                        </td>
                        <td v-else-if="item.completionRate=='-'">{{item.completionRate}}</td>
                        <td v-else>-</td>
                    </template>

                    <td v-if="isCheckRegionName(item)" class="openUserBox" :attrid="item.userId"
                        @click="lookPersonnelDepartList(item)">
                        <span v-if="item.managerName">{{item.managerName}}</span>
                        <span v-else style="color: #CCCCCC;">空缺</span>
                    </td>
                    <td v-else>
                        <span v-if="item.managerName">{{item.managerName}}</span>
                        <span v-else style="color: #CCCCCC;">空缺</span>
                    </td>


                    </td>
                    <td v-if="visitCustomer.time.length!=10">{{item.signManagerNum}}</td>
                    <template v-if="visitCustomer.time.length!=10">
                        <td v-if="isCheckRegionName(item)" @click="openAbnormal(item)"
                            :style="item.ycNum!='-'?'color:red;cursor:pointer':''">{{item.ycNum}}
                        </td>
                        <td v-else :style="item.ycNum!='-'?'color:red;cursor:pointer':''">
                            {{item.ycNum}}
                        </td>
                    </template>

                    <td v-if="visitCustomer.time.length!=10">{{item.averageComplete}}</td>
                    <td v-if="visitCustomer.time.length==10" class="lineOne"
                        style="border-left: 1px solid #cbcbcd;">
                        <span style="text-align: center">{{item.signTime?item.signTime.split(' ')[1]:'请假'}}</span>
                    </td>
                    <td v-if="visitCustomer.time.length==10" class="lineOne">
                        <span style="text-align: center">{{item.arrivalsTime.split(' ')[1]}}</span>
                    </td>
                    <td v-if="visitCustomer.time.length==10" class="lineOne">
                        <span style="text-align: center"
                              :style="timeJq(item.signInTimeDiff)?'':'color:red'"
                              v-if="item.arrivalsTime&&item.arrivalsTime!=''">{{addZeroHour(quMiao(item.signInTimeDiff))}}</span>
                    </td>
                    <td v-if="visitCustomer.time.length==10" class="lineOne">
                        <span style="text-align: center"
                              :style="dJq(item.signInDistance)?'':'color:red'"
                              v-if="item.signInTimeDiff != ''&&item.arrivalsTime&&item.arrivalsTime!=''">{{dJq(item.signInDistance)}}</span>
                    </td>
                    <td v-if="visitCustomer.time.length==10" class="lineOne">
                        <span style="text-align: center" v-if="item.arrivalsTime&&item.arrivalsTime!=''">{{disJq(item.signInSpeed)}}</span>
                    </td>
                    <td v-if="(visitCustomer.time==today && a==1)||visitCustomer.time==yesterday&&visitCustomer.time.length==10"
                        class="lineOne" style="border-left: 2px solid #169bd5;"><span
                            style="text-align: center">{{item.signOutTime.split(' ')[1]}}</span>
                    </td>
                    <td v-if="(visitCustomer.time==today && a==1)||visitCustomer.time==yesterday&&visitCustomer.time.length==10"
                        class="lineOne">
                        <span style="text-align: center" v-if="item.signOutTime">{{item.leaveTime.split(' ')[1]}}</span>
                    </td>
                    <td v-if="(visitCustomer.time==today && a==1)||visitCustomer.time==yesterday&&visitCustomer.time.length==10"
                        class="lineOne">
                        <span style="text-align: center"
                              :style="timeJq(item.signOutTimeDiff)?'':'color:red'">{{addZeroHour(quMiao(item.signOutTimeDiff))}}</span>
                    </td>
                    <td v-if="(visitCustomer.time==today && a==1)||visitCustomer.time==yesterday&&visitCustomer.time.length==10"
                        class="lineOne">
                        <span style="text-align: center" v-if="item.signOutTimeDiff != ''"
                              :style="dJq(item.signOutDistance)?'':'color:red'">{{dJq(item.signOutDistance)}}</span>
                    </td>
                    <td v-if="(visitCustomer.time==today && a==1)||visitCustomer.time==yesterday&&visitCustomer.time.length==10"
                        class="lineOne">
                        <span style="text-align: center">{{disJq(item.signOutSpeed)}}</span>
                    </td>
                    <td><span v-if="item.bigManagerName">{{item.bigManagerName}}</span>
                        <span v-else style="color: #CCCCCC;">空缺</span>
                    </td>
                    <td class="lineOne" style="border-left: 1px solid #cbcbcd;">
                        <span style="text-align: left;">{{item.departName}}</span>
                    </td>
                    <td v-if="visitCustomer.time==today &&a==0" class="lineOne"
                        style="border-left: 1px solid #cbcbcd;">
                        <span style="text-align: left;" v-if="item.arrivalsTime&&item.arrivalsTime!=''">{{isFair(item)}}</span>
                    </td>

                </tr>
                <tr v-if="!(visitCustomer.time==today  &&( a==0 || a==2))">
                    <td>合计</td>
                    <td>{{allDate[1].allComplete}}</td>
                    <td>-</td>
                    <td>-</td>
                    <!--今日昨日-->
                    <template v-if="visitCustomer.time==today || visitCustomer.time==yesterday">
                        <td>-</td>
                        <td>-</td>
                        <td>-</td>
                        <td>-</td>
                        <td>-</td>
                        <td style="border-left: 2px solid #169bd5;">-</td>
                        <td>-</td>
                        <td>-</td>
                        <td>-</td>
                        <td>-</td>
                    </template>
                    <template v-else>
                        <td>{{allDate[1].signManagerNum}}</td>
                        <td>{{allDate[1].ycNum}}</td>
                        <td>-</td>
                    </template>
                    <td>-</td>
                    <td>-</td>
                </tr>
                </tbody>
            </table>
            <table class="table text-center table-width table-bordered"
                   v-if="visitCustomer.time==today &&a==2">
                <thead>
                <tr>
                    <th style="width:6%;" class="tableTitle">区域经理</th>
                    <th style="width: 6%;border-left: 1px solid #cbcbcd;" class="tableTitle">上午末面<br>签退时间
                    </th>
                    <th style="width: 6%;" class="tableTitle">下午首面<br>签到时间</th>
                    <th style="width: 7%;" class="tableTitle">时间间隔</th>
                    <th style="width: 6%;" class="tableTitle">距离间隔<br>(公里)</th>
                    <th style="width: 6%;" class="tableTitle">时速<br>(km/h)</th>
                    <th style="width:6%;" class="tableTitle">大区经理</th>
                    <th style="border-left: 1px solid #cbcbcd;" class="tableTitle">大区</th>
                    <th v-if="visitCustomer.time==today &&a==2" class="tableTitle"
                        style="border-left: 1px solid #cbcbcd;width: 48%;">备注
                    </th>
                </tr>
                </thead>
                <tbody v-cloak>
                <tr v-for="(item,i) in visitCustomer.faceList">
                    <td v-if="isCheckRegionName(item)" class="openUserBox" :attrid="item.userId"
                        @click="lookPersonnelDepartList(item)">
                        <span v-if="item.managerName">{{item.managerName}}</span>
                        <span v-else style="color: #CCCCCC;">空缺</span>
                    </td>
                    <td v-else>
                        <span v-if="item.managerName">{{item.managerName}}</span>
                        <span v-else style="color: #CCCCCC;">空缺</span>
                    </td>
                    <td class="lineOne"
                        style="border-left: 1px solid #cbcbcd;">
                        <span style="text-align: center">{{item.amLeaveTime?item.amLeaveTime.split(' ')[1]:'请假'}}</span>
                    </td>
                    <td class="lineOne">
                        <span style="text-align: center">{{item.pmArrivalsTime.split(' ')[1]}}</span>
                    </td>
                    <td class="lineOne">
                        <span style="text-align: center"
                              :style="timeJq(item.signInPmTimeDiff)?'':'color:red'">{{addZeroHour(quMiao(item.signInPmTimeDiff))}}</span>
                    </td>
                    <td class="lineOne">
                        <span style="text-align: center"
                              :style="dJq(item.signInPmDistance)?'':'color:red'" v-if="item.signInPmTimeDiff != ''">{{dJq(item.signInPmDistance)}}</span>
                    </td>
                    <td class="lineOne">
                        <span style="text-align: center">{{disJq(item.signInPmSpeed)}}</span>
                    </td>
                    <td><span v-if="item.bigManagerName">{{item.bigManagerName}}</span>
                        <span v-else style="color: #CCCCCC;">空缺</span>
                    </td>
                    <td class="lineOne" style="border-left: 1px solid #cbcbcd;">
                        <span style="text-align: left;">{{item.departName}}</span>
                    </td>
                    <td v-if="visitCustomer.time==today &&a==2" class="lineOne"
                        style="border-left: 1px solid #cbcbcd;">
                        <span style="text-align: left;">{{isFair(item)}}</span>
                    </td>

                </tr>
                </tbody>
            </table>
        </div>
        <div style="width: 1100px;margin:0 auto;" class="mScrollBox"
             v-if="!(visitCustomer.time==today &&( a==0 || a==2))">
            <table class="table text-center table-width table-bordered">
                <thead>
                <tr>
                    <!--<th align="center" style="width:40px">序号</th>-->
                    <th style="width:6%;" v-if="!(visitCustomer.time==today &&( a==0 || a==2))" class="tableTitle">电访<br>排名</th>
                    <th v-if="!(visitCustomer.time==today &&( a==0 || a==2))"
                        style="width:6%;" class="tableTitle">完成
                    </th>
                    <th v-if="!(visitCustomer.time==today &&( a==0 || a==2))"
                        style="width:6%;" class="tableTitle">完成率
                    </th>
                    <th style="width:6%;" class="tableTitle">区域经理</th>
                    <th style="width:6%;" class="tableTitle">大区经理</th>
                    <th v-if="visitCustomer.time.length!=10" style="width:6%;" class="tableTitle">出勤天数</th>
                    <th v-if="visitCustomer.time.length!=10" style="width:6%;" class="tableTitle">日均完成</th>
                    <!--<th style="border-left: 1px solid #cbcbcd;" v-if="visitCustomer.time.length!=10">大区</th>-->
                    <th style="border-left: 1px solid #cbcbcd;" class="tableTitle">大区</th>
                </tr>
                </thead>
                <tbody v-cloak>
                <tr v-for="(item,i) in visitCustomer.telList">
                    <!--<td>{{i+1}}</td>-->
                    <td v-if="!(visitCustomer.time==today &&( a==0 || a==2))">{{item.rownum}}</td>
                    <template
                            v-if="!(visitCustomer.time==today &&( a==0 || a==2))">
                        <td style="color:#169BD5;cursor: pointer" @click="openInterview(item,'0')"
                            v-if="!(visitCustomer.time==today &&( a==0 || a==2))&&item.complete!='-'&&isCheckRegionName(item)">
                            {{item.complete}}
                        </td>
                        <td v-else>{{item.complete}}</td>
                    </template>
                    <template
                            v-if="!(visitCustomer.time==today &&( a==0 || a==2))">
                        <td v-if="item.completionRate!=''&&item.completionRate!='-'">
                            {{item.completionRate}}%
                        </td>
                        <td v-else-if="item.completionRate=='-'">{{item.completionRate}}</td>
                        <td v-else></td>
                    </template>
                    <td v-if="isCheckRegionName(item)" class="openUserBox" :attrid="item.userId"
                        @click="lookPersonnelDepartList(item)">
                        <span v-if="item.managerName">{{item.managerName}}</span>
                        <span v-else style="color: #CCCCCC;">空缺</span>
                    </td>
                    <td v-else>
                        <span v-if="item.managerName">{{item.managerName}}</span>
                        <span v-else style="color: #CCCCCC;">空缺</span>
                    </td>
                    <td><span v-if="item.bigManagerName">{{item.bigManagerName}}</span>
                        <span v-else style="color: #CCCCCC;">空缺</span>
                    </td>
                    <td v-if="visitCustomer.time.length!=10">{{item.signManagerNum}}</td>
                    <td v-if="visitCustomer.time.length!=10">{{item.averageComplete}}</td>
                    <td style="border-left: 1px solid #cbcbcd;text-align: left;">
                        {{item.departName}}
                    </td>

                </tr>
                <tr v-if="!(visitCustomer.time==today &&( a==0 || a==2))">
                    <td>合计</td>
                    <td v-if="!(visitCustomer.time==today &&( a==0 || a==2))">
                        {{allDate[0].allComplete}}
                    </td>
                    <td v-if="!(visitCustomer.time==today &&( a==0 || a==2))">
                        -
                    </td>
                    <td>-</td>
                    <td>-</td>
                    <td v-if="visitCustomer.time.length!=10">{{allDate[0].signManagerNum}}</td>
                    <td v-if="visitCustomer.time.length!=10">-</td>
                    <td style="border-left: 1px solid #cbcbcd;">-</td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>

    <!-- /.box-body -->
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=602456c3"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=6348cbbc"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script type="text/javascript" src="/dist/plugins/highcharts/highcharts.js"></script>
<script>
    $(function () {
        $("body").on("click", ".lineOne,.lineTwo", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + 80 + "px",
                        "left": $(this).offset().left - 6,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });
</script>
<script type="text/javascript">
    $(function () {
        $("body").on("click", ".reginTd", function (e) {
            var text = $(this).text();
            if (text != "") {
                text = "<i></i>" + text;
                $(".div-td-content-more").html(text).css({
                    "width": $(this).outerWidth() + "px",
                    "left": $(this).offset().left,
                    "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                }).show();
                e.stopPropagation();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });

    });

</script>
<script type="text/javascript">
    console.log(urlConfig);
    var app = new Vue({
        el: '#app',
        data: {
            currentUser: getCurrentUser(),
            companyId: $.wyui.page.urlParams.companyId,
            months: [],
            dateTime: $.wyui.page.urlParams.dateTime,
            yesterday: new Date(new Date() - 24 * 60 * 60 * 1000).Format("yyyy-MM-dd"),
            today: new Date().Format("yyyy-MM-dd"),
            thisMonth: new Date().Format("yyyy-MM"),
            thisWeek: new Date().Format("yyyy-MM-dd") + "-w",
            hour: new Date().getHours(),
            tab: [],
            regionNames: [],//该人员拥有的区域列表名称
            reginIds: [],
            a: 1,
            visitCustomer: {
                time: $.wyui.page.urlParams.dateTime,
                faceList: [],
                telList: [],
            },
            allDate: [
                {"allComplete": "", "completionRate": "", "ycNum": ""},
                {"allComplete": "", "completionRate": ""}
            ],
            userBox: {
                name: '',
                tel: '',
                roleName: '',
                entryDate: '',
                dayNumber: ''
            }
        },
        methods: {
            isFair: function (item) {
                var str = '';
               /* if (!this.distanceJq(item.signInDistance) && !this.timeJq(item.signInTimeDiff)) {
                    str = "距离、时间不合理"
                } else if (!this.distanceJq(item.signInDistance)) {
                    str = "距离不合理"
                } else if (!this.timeJq(item.signInTimeDiff)) {
                    str = "时间不合理"
                }*/
                return str
            },
            //距离合理->true 不合理->false
            distanceJq: function (d) {
                var str = d.replace("公里", "");
                /*return Number(str) < 15*/
                return true;
            },
            //时间合理->true 不合理->false
            timeJq: function (t) {
                /*if (t.indexOf("小时") > 0) {
                    var hour = t.split("小时")[0];
                    if (Number(hour) > 0) {
                        return false;
                    }
                } else {
                    if (t.indexOf("分") > 0) {
                        var min = t.split("分")[0];
                        if (Number(min) > 30) {
                            return false;
                        }
                    } else {
                        return true;
                    }
                }*/
                return true;
            },
            //距离间隔
            dJq: function (d) {
                var str = d.replace("公里", "");
                console.log("距离间隔 = " + str)
                if (str == '0') {
                    return '';
                } else {
                    return Number(str).toFixed(2);
                }
            },
            //速度
            disJq: function (dis) {
                var str = dis.replace("km/h", "");
                return str;
            },
            //去秒加0几分
            quMiao: function (m) {
                if (!m) return ""
                //1小时11分11秒
                var hour = "0"
                var min = "0"
                var sec = "0"

                if (m.indexOf("小时") > 0) {
                    //{1  , 11分11秒} 1小时55秒
                    hour = m.split("小时")[0]
                }
                if (m.indexOf("分") > 0) {
                    //{1小时11，11秒}
                    min = m.split("分")[0]
                    if (min.indexOf("小时") > 0) {
                        //{1,11}
                        min = min.split("小时")[1]
                    }
                    if (Number(min) < 10) {
                        min = "0" + min
                    }
                }
                if (min == "0" && m.indexOf("秒") > 0) {
                    //21秒
                    return hour + "小时01分"
                }
                return hour + "小时" + min + "分"
            },
            //添加0小时xx分
            addZeroHour: function (h) {
                if (!h) {
                    return ""
                }
                if (h.indexOf('小时') > 0) {
                    return h
                } else {
                    return "0小时" + h
                }
            },
            //tab中点击日期刷新对应数据
            refreshData: function (dataType, fun, time) {

                var that = this;
                that[dataType].time = time;
                that[fun]();
            },
            //获取tab
            getTab: function () {
                var that = this;
                var dateTime = new Date().Format("yyyyMM");

                for (var i = 0; i < 5; i++) {
                    dateTime = that.getLastEndMonth(dateTime);
                    that.tab.push(that.insert_flg(dateTime, "-", "4"))
                }
                console.log(that.tab)
            },
            isActive: function (item) {
                var that = this;
                if (that.visitCustomer.time == item) {
                    return true;
                }
            },
            getLastEndMonth: function (beginYearMonth) {
                var strYear = parseInt(beginYearMonth.substr(0, 4), 10);
                var strMonth = parseInt(beginYearMonth.substr(4, 6), 10);
                if (strMonth - 1 == 0) {
                    strYear -= 1;
                    strMonth = 12;
                } else {
                    strMonth -= 1;
                }
                if (strMonth < 10) {
                    strMonth = "0" + strMonth;
                }
                var monthstr = strYear + "" + strMonth;
                return monthstr;
            },
            //格式化日期
            insert_flg: function (str, flg, sn, type) {
                var newstr = "";
                for (var i = 0; i < str.length; i += sn) {
                    var tmp = str.substring(i, i + sn);
                    newstr += tmp + flg;
                }
                newstr = newstr.substr(0, newstr.length - 1);
                var st1 = newstr.substr(2, 2);
                var st2 = newstr.substr(5, 2);
                var newstr3 = st2 + "/" + st1;
                var obj = {str: newstr, time: newstr};
                return obj;
            },
            isHasRightOp: function (regionId) {
//                console.log($.inArray(regionId, this.reginIds) > -1)
                return $.inArray(regionId, this.reginIds) > -1;
            },
            isGo: function (item) {
                var that = this;
                if (that.isHasRightOp(item.regionId)) {
                    return true
                } else {
                    return false
                }
            },
            getCount: function (arr, key) {
                var number = 0;
                for (var i = arr.length - 1; i >= 0; i--) {
                    number += (arr[i][key] && arr[i][key] != '-' ? arr[i][key] : 0)

                }
                return number;
            },
            lookPersonnelDepartList: function (item) {
                top.addTabs({
                    id: "look" + item.id,
                    title: item.managerName + "详情",
                    close: true,
                    url: '/personnel/entry.html?id=' + item.userId + '&pageType=look'
                });
            },
            getAll: function (arr, type) {
                console.log(this.regionInfo)
                if (type == "0") {
                    this.allDate[0].target = this.getCount(arr, "target");
                    this.allDate[0].allComplete = this.getCount(arr, "complete");
                    this.allDate[0].signManagerNum = this.getCount(arr, "signManagerNum");
                    /*
                     this.allDate[0].averageComplete = (this.allDate[0].allComplete / this.allDate[0].signManagerNum).toFixed(2);
                     */
                    if (this.allDate[0].target == 0) {
                        this.allDate[0].completionRate = "0.00%";
                    } else {
                        this.allDate[0].completionRate = (this.allDate[0].allComplete / this.allDate[0].target * 100).toFixed(2) + "%";
                    }
                } else {
                    this.allDate[1].target = this.getCount(arr, "target");
                    this.allDate[1].allComplete = this.getCount(arr, "complete");
                    this.allDate[1].signManagerNum = this.getCount(arr, "signManagerNum");
                    this.allDate[1].ycNum = this.getCount(arr, "ycNum");
                    /*
                     this.allDate[1].averageComplete = (this.allDate[1].allComplete / this.allDate[1].signManagerNum).toFixed(2);
                     */
                    if (this.allDate[1].target == 0) {
                        this.allDate[1].completionRate = "0.00%";
                    } else {
                        this.allDate[1].completionRate = (this.allDate[1].allComplete / this.allDate[1].target * 100).toFixed(2) + "%";
                    }
                }
            },
            getRegionByUserId: function () {
                var that = this;
                $.wyui.postMethod(urlConfig.report.visitCustomer.getRegionByUserId, {userId: getCurrentUser().id}, function (ids) {
                    for (var i = 0; i < ids.length; i++) {
                        that.reginIds.push(ids[i].regionId);
                    }
//                    console.log(that.reginIds)
                }, true);
            },
            //获取拜访报表-区域经理
            get_visitDepart: function () {
                var that = this;
                $.wyui.postMethod(urlConfig.report.visitCustomer.getAllManagerByCompanyId, {
                    "companyId": that.companyId,
                    "dateTime": that.visitCustomer.time,
                    "type": "1"
                }, function (data) {
                    var data = trimRN2(data);
                    that.visitCustomer.faceList = data;
                    that.getAll(that.visitCustomer.faceList, "1");
                }, false, "#visitRegion");
                $.wyui.postMethod(urlConfig.report.visitCustomer.getAllManagerByCompanyId, {
                    "companyId": that.companyId,
                    "dateTime": that.visitCustomer.time,
                    "type": "0"
                }, function (data) {
                    var data = trimRN2(data);
                    that.visitCustomer.telList = data;
                    that.getAll(that.visitCustomer.telList, "0");
                }, false, "#visitRegion");
            },
            getRegionNameByUserId: function () {
                var that = this;
                $.wyui.postMethod(urlConfig.report.visitCustomer.getForDepartByUserIdForClick, {userId: getCurrentUser().id}, function (ids) {
                    for (var i = 0; i < ids.length; i++) {
                        that.regionNames.push(ids[i].regionName);
                    }
                }, true);
            },
//            //查拜访个人下级页面
//            lookInterviewCustomerList:function(item,type){
//                var that=this;
//                url = "reportForm/interview/interviewCustomerList.html";
//                top.closeTabByPageId("lookInterviewCustomerList");
//                top.addTabs({id:"lookInterviewCustomerList",title:item.managerName,close: true,url:url+ '?userId=' +item.userId+"&dateTime="+that.visitCustomer.time});
//            },
//            lookInterview:function(item,type){
//                var that=this;
//                url = "/page/reportForm/interview/interviewCustomerList.html";
//                $.dialog({
//                    content: 'url:'+url+'?userId=' + item.userId+"&dateTime="+that.visitCustomer.time+"&name="+item.managerName+"&type="+type,
//                    title: '客户列表',
//                    width: 600,
//                    height: 500,
//                    max: false,
//                    min: false,
//                    lock: true
//                });
//            },
            openInterview: function (item, type) {
                var that = this;
                top.closeTabByPageId("khList2");
                top.addTabs({
                    id: 'khList2',
                    title: type == 1 ? item.managerName + '面访' : item.managerName + '电访',
                    close: true,
                    url: 'reportForm/interview/interviewCustomerList.html?userId=' + item.userId + "&dateTime=" + that.visitCustomer.time + "&name=" + item.managerName + "&type=" + type,
                });
            },
//            openAbnormal
            openAbnormal: function (item) {
                var that = this;
                top.closeTabByPageId("interviewYc");
                top.addTabs({
                    id: 'interviewYc',
                    title: '本月面访详情',
                    close: true,
                    url: 'reportForm/interview/interviewAbnormal.html?userId=' + item.userId + "&dateTime=" + that.visitCustomer.time + '&managerName=' + item.managerName,
                });
            },
            isCheckRegionName: function (item) {
                var that = this;
                if (that.isHasregionNameOp(item.departName)) {
                    return true
                } else {
                    return false
                }
            },
            isHasregionNameOp: function (departName) {
                // console.log($.inArray(regionName, this.regionNames) > -1)
                return $.inArray(departName.replace('大区', ''), this.regionNames) > -1;
            },
        },
        mounted: function () {
            var that = this;
            //获取前5个月 拼接出日期筛选框
            //查看参数
            if (!that.companyId) {
                that.companyId = getCurrentUser().companyId;
            }
            if (!that.dateTime) {
                that.dateTime = new Date().Format("yyyy-MM-dd");
            }
            //获取前5个月的tab数据
            this.getTab();
            //获取数据
            //获取可查看区域权限
            that.getRegionByUserId();
            that.getRegionNameByUserId();
            that.get_visitDepart();
        }

    });
</script>
</body>
</html>